---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: atlassian-confluence
spec:
  replicas: 1
  template:
    metadata:
      labels:
        name: atlassian-confluence
        app: atlassian-confluence
    
    spec:

      # initContainers:
      # - name: mysql-driver
      #   image: busybox
      #   command: ["wget -qO- https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.1.45.tar.gz | tar xvz mysql-connector-java-5.1.45/mysql-connector-java-5.1.45-bin.jar && mv mysql-connector-java-5.1.45/mysql-connector-java-5.1.45-bin.jar /opt/atlassian/confluence/WEB-INF/lib"]
      
      containers:

      - name: atlassian-confluence
        image: atlassian/confluence-server:latest
        imagePullPolicy: Always
        env:

        - name: JVM_MINIMUM_MEMORY
          value: "1024m"
        - name: JVM_MAXIMUM_MEMORY
          value: "1024m"
        - name: CATALINA_OPTS
          value: "-Xms1024m -Xmx1024m"
        - name: CATALINA_CONNECTOR_PROXYNAME
          value: "docs.streaming-platform.com"
        - name: CATALINA_CONNECTOR_PROXYPORT
          value: "443"
        - name: CATALINA_CONNECTOR_SCHEME
          value: "https"
        - name: CATALINA_CONNECTOR_SECURE
          value: "true"

        ports:
        - name: http
          containerPort: 8090
        - name: control
          containerPort: 8091

        livenessProbe:
          httpGet:
            path: /rest/applinks/latest/manifest
            port: 8090
          initialDelaySeconds: 180
          timeoutSeconds: 15

        readinessProbe:
          httpGet:
            path: /rest/applinks/latest/manifest
            port: 8090
          initialDelaySeconds: 15
          timeoutSeconds: 1

        volumeMounts:

          - mountPath: /var/www/html
            name: empty

          - mountPath: /var/atlassian/application-data/confluence
            name: atlassian-confluence-persistent-storage
      
      volumes:

        - name: empty
          emptyDir: {}

        - name: atlassian-confluence-persistent-storage
          persistentVolumeClaim:
            claimName: atlassian-confluence-persistent-storage
---
apiVersion: v1
kind: Service
metadata:
  name: atlassian-confluence
  labels:
    name: atlassian-confluence
spec:
  type: NodePort
  selector:
    name: atlassian-confluence
  ports:
    - name: http
      port: 8090
      targetPort: 8090

---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: atlassian-confluence-persistent-storage
  labels:
    app: atlassian-confluence-persistent-storage
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 4Gi